
#include <sys/un.h>
#include <sys/socket.h>
#include <sys/types.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>

#define SOCK_NAME "mysocket"

int main()
{
	struct sockaddr_un saddr;
	int sockid, len;
	char m[100];
	sockid = socket(PF_UNIX, SOCK_DGRAM, 0);
	if(sockid <  0) {
		printf("sockid error");
		exit(-1);
	}
	saddr.sun_family = AF_UNIX;
	strcpy(saddr.sun_path, SOCK_NAME);
	do {
		fgets(m, 100, stdin);
		len = sendto(sockid, m, strlen(m), 0, (struct sockaddr *)&saddr, SUN_LEN(&saddr));
	} while(len >= 0 && strcmp(m, "exit\n"));
	close(sockid);
	return 0;
}
